/* common.js */
var globalData = {
  // 阿里云  设备身份三元组 + 区域
  Aliyun_deviceConfig: {
    productKey: "a1f0EpcAL0b",
    deviceName: "wechat_App",
    deviceSecret: "70bf8bc7b065594927fdf42665d5214f",
    regionId: "cn-shanghai"
  },
  mqtt_client: 0,
  // 控制界面的变量信息
  Fan: {
    Status: 0,
    Network: 0,
    Power: 0,
    cmd:0
  },
  Buzzer: {
    Status: 0,
    Network: 0,
    Power: 0,
    cmd: 0
  },
  Relay:{
    Status: 0,
    Network: 0,
    Power: 0,
    cmd: 0
  },
  threshold:{
    Temperature:{
      Upper: 50,
      Lower: -20,
    },
    Humidity:{
      Upper: 90,
      Lower: 10,  
    },
    Flame:{
      Upper: 0,
      Lower: 0,
    },
    Smoke:{
      Upper: 0,
      Lower: 0,
    },
    Raindrop:{
      Upper: 0,
      Lower: 0,
    },
    Combustible:{
      Upper: 0,
      Lower: 0,
    },
    Light: {
      Upper: 0,
      Lower: 0,
    },
    Potentiometer: {
      Upper: 0,
      Lower: 0,
    }
  }
}
/************* set Data Value function *************/
function set_message_Fan_Status(value) { globalData.Fan.Status = value }
function set_message_Fan_Network(value) { globalData.Fan.Network = value }
function set_message_Fan_Power(value) { globalData.Fan.Power = value }
function set_message_Fan_cmd(value) { globalData.Fan.cmd = value }

function set_message_Buzzer_Status(value) { globalData.Buzzer.Status = value }
function set_message_Buzzer_Network(value) { globalData.Buzzer.Network = value }
function set_message_Buzzer_Power(value) { globalData.Buzzer.Power = value }
function set_message_Buzzer_cmd(value) { globalData.Fan.cmd = value }

function set_message_Relay_Status(value) { globalData.Relay.Status = value }
function set_message_Relay_Network(value) { globalData.Relay.Network = value }
function set_message_Relay_Power(value) { globalData.Relay.Power = value }
function set_message_Relay_cmd(value) { globalData.Relay.cmd = value }

function set_message_MQTT_Client(value) { globalData.mqtt_client = value }

function set_message_TemperatureUpper(value) { globalData.threshold.Temperature.Upper = value }
function set_message_TemperatureLower(value) { globalData.threshold.Temperature.Lower = value }
function set_message_HumidityUpper(value) { globalData.threshold.Humidity.Upper = value }
function set_message_HumidityLower(value) { globalData.threshold.Humidity.Lower = value }
function set_message_FlameUpper(value) { globalData.threshold.Flame.Upper = value }
function set_message_FlameLower(value) { globalData.threshold.Flame.Lower = value }
function set_message_SmokeUpper(value) { globalData.threshold.Smoke.Upper = value }
function set_message_SmokeLower(value) { globalData.threshold.Smoke.Lower = value }
function set_message_RaindropUpper(value) { globalData.threshold.Raindrop.Upper = value }
function set_message_RaindropLower(value) { globalData.threshold.Raindrop.Lower = value }
function set_message_CombustibleUpper(value) { globalData.threshold.Combustible.Upper = value }
function set_message_CombustibleLower(value) { globalData.threshold.Combustible.Lower = value }
function set_message_LightUpper(value) { globalData.threshold.Light.Upper = value }
function set_message_LightLower(value) { globalData.threshold.Light.Lower = value }
function set_message_PotentiometerUpper(value) { globalData.threshold.Potentiometer.Upper = value }
function set_message_PotentiometerLower(value) { globalData.threshold.Potentiometer.Lower = value }

/************* get Data Value function *************/
function get_message_Fan_Status() { return globalData.Fan.Status }
function get_message_Fan_Network() { return globalData.Fan.Network }
function get_message_Fan_Power() { return globalData.Fan.Power }
function get_message_Fan_cmd() { return globalData.Fan.cmd }

function get_message_Buzzer_Status() { return globalData.Buzzer.Status }
function get_message_Buzzer_Network() { return globalData.Buzzer.Network }
function get_message_Buzzer_Power() { return globalData.Buzzer.Power }
function get_message_Buzzer_cmd() { return globalData.Buzzer.cmd }

function get_message_Relay_Status() { return globalData.Relay.Status }
function get_message_Relay_Network() { return globalData.Relay.Network }
function get_message_Relay_Power() { return globalData.Relay.Power }
function get_message_Relay_cmd() { return globalData.Relay.cmd }

function get_message_MQTT_Client() { return globalData.mqtt_client }

function get_message_Aliyun() { return globalData.Aliyun_deviceConfig }
function get_message_Aliyun_ProductKey() { return globalData.Aliyun_deviceConfig.productKey }
function get_message_Aliyun_DeviceName() { return globalData.Aliyun_deviceConfig.deviceName }
function get_message_Aliyun_DeviceSecret() { return globalData.Aliyun_deviceConfig.deviceSecret }
function get_message_Aliyun_RegionId() { return globalData.Aliyun_deviceConfig.regionId }

function get_message_TemperatureUpper() { return globalData.threshold.Temperature.Upper }
function get_message_TemperatureLower() { return globalData.threshold.Temperature.Lower }
function get_message_HumidityUpper() { return globalData.threshold.Humidity.Upper }
function get_message_HumidityLower() { return globalData.threshold.Humidity.Lower }
function get_message_FlameUpper() { return globalData.threshold.Flame.Upper }
function get_message_FlameLower() { return globalData.threshold.Flame.Lower }
function get_message_SmokeUpper() { return globalData.threshold.Smoke.Upper }
function get_message_SmokeLower() { return globalData.threshold.Smoke.Lower }
function get_message_RaindropUpper() { return globalData.threshold.Raindrop.Upper }
function get_message_RaindropLower() { return globalData.threshold.Raindrop.Lower }
function get_message_CombustibleUpper() { return globalData.threshold.Combustible.Upper }
function get_message_CombustibleLower() { return globalData.threshold.Combustible.Lower }
function get_message_LightUpper() { return globalData.threshold.Light.Upper }
function get_message_LightLower() { return globalData.threshold.Light.Lower }
function get_message_PotentiometerUpper() { return globalData.threshold.Potentiometer.Upper }
function get_message_PotentiometerLower() { return globalData.threshold.Potentiometer.Lower }

module.exports = { 
  set_message_Fan_Status : set_message_Fan_Status,
  set_message_Fan_Network: set_message_Fan_Network,
  set_message_Fan_Power  : set_message_Fan_Power, 
  set_message_Fan_cmd  : set_message_Fan_cmd, 

  set_message_Buzzer_Status : set_message_Buzzer_Status,
  set_message_Buzzer_Network: set_message_Buzzer_Network,
  set_message_Buzzer_Power  : set_message_Buzzer_Power,  
  set_message_Buzzer_cmd  : set_message_Buzzer_cmd,  

  set_message_Relay_Status : set_message_Relay_Status,
  set_message_Relay_Network: set_message_Relay_Network,
  set_message_Relay_Power  : set_message_Relay_Power, 
  set_message_Relay_cmd  : set_message_Relay_cmd, 

  set_message_MQTT_Client  : set_message_MQTT_Client, 
  set_message_TemperatureUpper : set_message_TemperatureUpper,
  set_message_TemperatureLower : set_message_TemperatureLower,
  set_message_HumidityUpper : set_message_HumidityUpper,
  set_message_HumidityLower : set_message_HumidityLower,
  set_message_FlameUpper : set_message_FlameUpper,
  set_message_FlameLower : set_message_FlameLower,
  set_message_SmokeUpper : set_message_SmokeUpper,
  set_message_SmokeLower : set_message_SmokeLower,
  set_message_RaindropUpper : set_message_RaindropUpper,
  set_message_RaindropLower : set_message_RaindropLower,
  set_message_CombustibleUpper : set_message_CombustibleUpper,
  set_message_CombustibleLower : set_message_CombustibleLower,
  set_message_LightUpper : set_message_LightUpper,
  set_message_LightLower : set_message_LightLower,
  set_message_PotentiometerUpper : set_message_PotentiometerUpper,
  set_message_PotentiometerLower : set_message_PotentiometerLower,

/*********************************************************************************************/
  get_message_Fan_Status : get_message_Fan_Status,
  get_message_Fan_Network: get_message_Fan_Network,
  get_message_Fan_Power  : get_message_Fan_Power, 
  get_message_Fan_cmd  : get_message_Fan_cmd, 

  get_message_Buzzer_Status : get_message_Buzzer_Status,
  get_message_Buzzer_Network: get_message_Buzzer_Network,
  get_message_Buzzer_Power  : get_message_Buzzer_Power,  
  get_message_Buzzer_cmd  : get_message_Buzzer_cmd,  

  get_message_Relay_Status : get_message_Relay_Status,
  get_message_Relay_Network: get_message_Relay_Network,
  get_message_Relay_Power  : get_message_Relay_Power, 
  get_message_Relay_cmd  : get_message_Relay_cmd, 

  get_message_MQTT_Client  : get_message_MQTT_Client, 
  get_message_Aliyun       : get_message_Aliyun, 
  get_message_Aliyun_ProductKey : get_message_Aliyun_ProductKey,
  get_message_Aliyun_DeviceName: get_message_Aliyun_DeviceName,
  get_message_Aliyun_DeviceSecret  : get_message_Aliyun_DeviceSecret, 
  get_message_Aliyun_RegionId       : get_message_Aliyun_RegionId, 
  get_message_TemperatureUpper : get_message_TemperatureUpper,
  get_message_TemperatureLower : get_message_TemperatureLower,
  get_message_HumidityUpper : get_message_HumidityUpper,
  get_message_HumidityLower : get_message_HumidityLower,
  get_message_FlameUpper : get_message_FlameUpper,
  get_message_FlameLower : get_message_FlameLower,
  get_message_SmokeUpper : get_message_SmokeUpper,
  get_message_SmokeLower : get_message_SmokeLower,
  get_message_RaindropUpper : get_message_RaindropUpper,
  get_message_RaindropLower : get_message_RaindropLower,
  get_message_CombustibleUpper : get_message_CombustibleUpper,
  get_message_CombustibleLower : get_message_CombustibleLower,
  get_message_LightUpper : get_message_LightUpper,
  get_message_LightLower : get_message_LightLower,
  get_message_PotentiometerUpper : get_message_PotentiometerUpper,
  get_message_PotentiometerLower : get_message_PotentiometerLower,
}
